package com.ruoyi.web.controller.swimming;

import java.util.List;

import com.ruoyi.swimming.domian.SwimmingTicketBindMember;
import com.ruoyi.swimming.service.ISwimmingTicketBindMemberService;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 绑定成员Controller
 * 
 * @author ruoyi
 * @date 2021-07-17
 */
@RestController
@RequestMapping("/system/member")
public class SwimmingTicketBindMemberController extends BaseController
{
    @Autowired
    private ISwimmingTicketBindMemberService swimmingTicketBindMemberService;

    /**
     * 查询绑定成员列表
     */
    @PreAuthorize("@ss.hasPermi('system:member:list')")
    @GetMapping("/list")
    public TableDataInfo list(SwimmingTicketBindMember swimmingTicketBindMember)
    {
        startPage();
        List<SwimmingTicketBindMember> list = swimmingTicketBindMemberService.selectSwimmingTicketBindMemberList(swimmingTicketBindMember);
        return getDataTable(list);
    }

    /**
     * 导出绑定成员列表
     */
    @PreAuthorize("@ss.hasPermi('system:member:export')")
    @Log(title = "绑定成员", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(SwimmingTicketBindMember swimmingTicketBindMember)
    {
        List<SwimmingTicketBindMember> list = swimmingTicketBindMemberService.selectSwimmingTicketBindMemberList(swimmingTicketBindMember);
        ExcelUtil<SwimmingTicketBindMember> util = new ExcelUtil<SwimmingTicketBindMember>(SwimmingTicketBindMember.class);
        return util.exportExcel(list, "绑定成员数据");
    }

    /**
     * 获取绑定成员详细信息
     */
    @PreAuthorize("@ss.hasPermi('system:member:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(swimmingTicketBindMemberService.selectSwimmingTicketBindMemberById(id));
    }

    /**
     * 新增绑定成员
     */
    @PreAuthorize("@ss.hasPermi('system:member:add')")
    @Log(title = "绑定成员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SwimmingTicketBindMember swimmingTicketBindMember)
    {
        return toAjax(swimmingTicketBindMemberService.insertSwimmingTicketBindMember(swimmingTicketBindMember));
    }

    /**
     * 修改绑定成员
     */
    @PreAuthorize("@ss.hasPermi('system:member:edit')")
    @Log(title = "绑定成员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SwimmingTicketBindMember swimmingTicketBindMember)
    {
        return toAjax(swimmingTicketBindMemberService.updateSwimmingTicketBindMember(swimmingTicketBindMember));
    }

    /**
     * 删除绑定成员
     */
    @PreAuthorize("@ss.hasPermi('system:member:remove')")
    @Log(title = "绑定成员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(swimmingTicketBindMemberService.deleteSwimmingTicketBindMemberByIds(ids));
    }
}
